#pragma once
#include <QVector>
#include "Database.h"
#include <Windows.h>
#include "Telephone.h"

#define BUFFER 4096
#define PIPENAME L"\\\\.\\pipe\\Phone"
#define SERVERNAME L"server.exe"

class Database
{
public:
	Database(void);
	~Database(void);

	int count() const;
	int append(Telephone &phone);
	void remove(int id);
	int update(const Telephone record);
	Telephone record(int id);
	void clear();
	bool save(void);
	bool load(void);
	QString readQString(HANDLE hFile);
	//QString readQString(HANDLE hFile/*, QString str*/);
	int writeQString(HANDLE hFile, const QString str);

	//bool operator > ( PhoneItem next1, PhoneItem next2);

	QVector<Telephone> data;

	const QVector<PhoneItem> records();
private:
	QVector<Telephone>::iterator it;

	int global;
};
